5.1. redux-toolkit

Redux documentation - https://redux.js.org/introduction/getting-started

redux toolkit documentation - https://redux-toolkit.js.org/introduction/getting-started

Redux is a JS library for predictable and maintainable global state management.

Redux Toolkit is official recommended approach for writing Redux logic. It wraps around the Redux core, and contains packages and functions that we think are essential for building a Redux app. Redux Toolkit builds in our suggested best practices, simplifies most Redux tasks, prevents common mistakes, and makes it easier to write Redux applications.

RTK includes utilities that help simplify many common use cases, including store setupcreating reducers and writing immutable update logic, and even creating entire "slices" of state at once.

Redux is a JavaScript library used to manage global state in an app. It stores all the app data in one place (called a store) and updates it using actions and reducers.

Redux Toolkit is the official, easier, and better way to write Redux logic. It reduces boilerplate code and gives useful tools out of the box like createSlice, configureStore, etc

here in react we install 2 packages

npm install @reduxjs/toolkit react-redux

You install 2 packages because:

  1. @reduxjs/toolkit is used to create and manage the Redux store easily.
  2. react-redux lets you use Redux with React components.

store - single source of truth
reducers
useSelector
useDispatch


more to study here

4. Context API

redux auth-login-logout

1. How session is be created in this project

4. Redux usecase for login,logout